cmake_minimum_required(VERSION 3.16)

project(lepure VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Qt6 REQUIRED COMPONENTS Core Quick Sql SerialPort)
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core)
find_package(Qt6 REQUIRED COMPONENTS Core)

qt_standard_project_setup(REQUIRES 6.8)

qt_add_executable(applepure
    main.cpp
)

qt_add_resources(APP_RESOURCES
    src.qrc
)

target_sources(applepure PRIVATE ${APP_RESOURCES})

qt_add_qml_module(applepure
    URI lepure
    VERSION 1.0
    QML_FILES Main.qml
    RESOURCES src.qrc
    SOURCES system.h
    SOURCES system.cpp
    SOURCES LineChartItem.h
    SOURCES LineChartItem.cpp
    SOURCES user.cpp user.h  db.cpp db.h u.cpp u.h
    SOURCES test.cpp test.h
    SOURCES serialportsync.cpp serialportsync.h
    SOURCES setting.h setting.cpp
    SOURCES collection.h collection.cpp
    SOURCES worker.h worker.cpp
    SOURCES alarm.h
    SOURCES alarm.cpp
    SOURCES global.h global.cpp
    SOURCES log.h log.cpp
    SOURCES command.h
    SOURCES batch.cpp batch.h
    QML_FILES component/ZButton.qml component/ZButtonImage.qml component/ZCheckImage.qml component/ZGlobal.js component/ZInputImage.qml component/ZInputMultiLineImage.qml component/ZLabelValue.qml component/ZLoaderAnimation.qml component/ZModelRect.qml pages/AboutPage.qml pages/AlarmPage.qml pages/AuditPage.qml pages/AutoPage.qml pages/BatchListPage.qml pages/BatchManagementPage.qml pages/BatchPage.qml pages/Card.qml pages/ChartPage.qml pages/CInput.qml pages/ConductivityCalibrationPage.qml pages/ConductivityPage.qml pages/EButton.qml pages/ECalendar.qml pages/ECheckBox.qml pages/EInput.qml pages/EmergencyPage.qml pages/KnobControl.qml pages/LoginPage.qml pages/LogPage.qml pages/MainPage.qml pages/ModifyPasswordPage.qml pages/ParameterRow.qml pages/PhCalibrationPage.qml pages/PhPage.qml pages/RangeSettingPage.qml pages/SerialPage.qml pages/SettingGroup.qml pages/SettingManagementPage.qml pages/SettingPage.qml pages/StirPage.qml pages/StopPage.qml pages/SystemTimePage.qml pages/TempDial.qml pages/TempPage.qml pages/TestBlueBox.qml pages/TestPage.qml pages/TestView.qml pages/Theme.qml pages/UserListPage.qml pages/UserManagementPage.qml pages/UserPage.qml pages/WeighPage.qml pages/WeightCalibrationPage.qml
SOURCES logmanager.h logmanager.cpp
SOURCES trigger.h
SOURCES trigger.cpp
SOURCES operation.h
SOURCES operation.cpp
SOURCES batchdata.h
SOURCES batchdata.cpp
SOURCES warn.h
SOURCES warn.cpp
)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(applepure PROPERTIES
#    MACOSX_BUNDLE_GUI_IDENTIFIER com.example.applepure
    MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
    MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
    MACOSX_BUNDLE TRUE
    WIN32_EXECUTABLE TRUE
)

target_link_libraries(
    applepure
    PRIVATE Qt6::Quick
            Qt6::Core
            Qt6::Sql
            Qt6::SerialPort
)
target_link_libraries(applepure PRIVATE Qt6::Core)
target_link_libraries(applepure PRIVATE Qt6::Core)
target_link_libraries(applepure PRIVATE Qt6::Core)
target_link_libraries(applepure PRIVATE Qt6::Core)

include(GNUInstallDirs)
install(TARGETS applepure
    BUNDLE DESTINATION .
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
